/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package helloworld;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import domain.*;
import facade.*;

/**
 *
 * @author rafael
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        System.out.println(" Hello-jar");
        //delete();
        save();
        //retreive();

    }

    public static void save(){

        System.out.println("Testando a conexão ...");
        ApplicationContext context = new
                ClassPathXmlApplicationContext("applicationContext.xml");

        Clientes clientes = new Clientes();


        //clientes.setId(30);
        clientes.setNome("Hell6");

        ClienteFacade instance = null;

        instance = (ClienteFacade)context.getBean("clienteFacade");

        Clientes expResult = null;

        Clientes result = null;
        result  = instance.save(clientes);

    }

    public static void delete(){


        int id_Exluir = 30;

        ApplicationContext context = new
           ClassPathXmlApplicationContext("applicationContext.xml");

        ClienteFacade instance = null;
        instance = (ClienteFacade)context.getBean("clienteFacade");

        Clientes cliente = null;
        cliente = instance.load(id_Exluir);
        instance.delete(cliente);

        Clientes searchCliente = instance.load(id_Exluir);
    }

    public static void retreive(){

        ApplicationContext context = new
              ClassPathXmlApplicationContext("applicationContext.xml");

        Integer id = 30;
        ClienteFacade instance = null;
        instance = (ClienteFacade)context.getBean("clienteFacade");

        Clientes expResult = null;
        Clientes result = instance.load(id);
    }
}
